//合作机构管理编辑。
Ext.define("ES.view.cooperation.CooperationEdit",{
    extend:"Ext.window.Window",
    alias:"widget.cooperationEdit",
    title:"合作机构",
    width:800,
    height:600,
    layout:"fit",
    modal:true,
    items:{
            xtype:"form",
            bodyPadding:5,
            defaultType:"textfield",
            frame:true,
            layout:"column",
            buttonAlign:"center",
            items:[{
                    xtype:"fieldset",
                    columnWidth:1,
                    title:"基本信息",
                    collapsible:false,
                    defaultType:"textfield",
                    layout:"column",
                    defaults:{
                            bodyPadding:4,
                            labelSeparator:":",
                            labelWidth:72,//标签宽度。
                            labelAlign:"right",
                            width:268,//字段宽度。
                            allowBlank:true,//是否允许为空。
                            blankText:"不允许为空",
                            msgTarget:"side"
                    },
                    items:[{
                            fieldLabel:"机构代码",
                            name:"cooperationCode",
                            columnWidth:.3,
                            allowBlank:false
                    },{
                            fieldLabel:"机构名称",
                            name:"cooperationName",
                            columnWidth:.4,
                            allowBlank:false
                    },{
                            fieldLabel:"合作方式",
                            xtype:"combo",
                            typeAhead:true,
                            triggerAction:"all",
                            selectOnTab:true,
                            store:"CooperationWayStore",
                            displayField:"WayText",
                            valueField:"WayValue",
                            value:0,
                            queryMode:"local",
                            lazyRender:true,
                            name:"cooperationWay",
                            columnWidth:.3,
                            allowBlank:false
                    },{
                            fieldLabel:"授权码",
                            name:"authorizationCode",
                            columnWidth:.3
                    },{
                            fieldLabel:"机构网站",
                            name:"hostURL",
                            columnWidth:.7
                    },{
                            xtype:"datefield",
                            fieldLabel:"合作时间",
                            name:"cooperationTime",
                            format:"Y-m-d",
                            value:new Date(),
                            columnWidth:.3
                    },{
                            fieldLabel:"站点Url",
                            name:"siteURL",
                            columnWidth:.7
                    },{
                            fieldLabel:"联系电话",
                            name:"telPhone",
                            columnWidth:.3
                    },{
                            fieldLabel:"邮箱地址",
                            name:"emailAddress",
                            columnWidth:.7
                    },{
                            fieldLabel:"联系人",
                            name:"linkName",
                            columnWidth:.3
                    },{
                            fieldLabel:"身份证号码",
                            name:"IDCard",
                            columnWidth:.4
                    },{
                            fieldLabel:"利润分成",
                            xtype:"numberfield",
                            decimalPrecision:2,
                            allowDecimals:true,
                            minValue:0,
                            minText:"不能小于0",
                            maxValue:1,
                            maxText:"不能大于1",
                            nanText:"请输入数字",
                            step:.1,
                            value:0,
                            name:"profitPercent",
                            columnWidth:.3
                    },{
                            fieldLabel:"开户银行",
                            name:"bankName",
                            columnWidth:.3
                    },{
                            fieldLabel:"银行卡号",
                            name:"bankNumber",
                            columnWidth:.4
                    },{
                            fieldLabel:"开户地址",
                            name:"bankAddress",
                            columnWidth:.3
                    },{
                            fieldLabel:"状态",
                            xtype:"combo",
                            typeAhead:true,
                            triggerAction:"all",
                            selectOnTab:true,
                            store:"StatusStore",
                            displayField:"StatusName",
                            valueField:"StatusValue",
                            value:1,
                            queryMode:"local",
                            lazyRender:true,
                            name:"status",
                            columnWidth:.3,
                            allowBlank:false
                    }]
            },{
                    xtype:"fieldset",
                    columnWidth:1,
                    title:"机构成员",
                    collapsible:false,
                    items:{
                            xtype:"gridpanel",
                            height:290,
                            store:"CooperationMemberStore",
                            frame:true,
                            layout:{
                                    type:"fit",
                                    align:"stretch"
                            },
                            sortableColumns:false,
                            viewConfig:{
                                    forceFit:true,
                                    columnLines:true,
                                    stripRows:true
                            },
                            tbar:[{
                                xtype:"button",
                                iconCls:"add-icon",
                                text:"新增合作机构成员",
                                handler:function(btn){
                                    var grid = btn.ownerCt.ownerCt;
                                    var st = grid.getStore();
                                    var model = Ext.create("ES.model.CooperationMemberModel");
                                    st.insert(0,model);
                                    var plugin = grid.getPlugin("RowEditingEx");
                                    var o =grid.getView().getHeaderAtIndex(0);
                                    plugin.startEdit(model,o);
                                }
                            }],
                            bbar:[{
                                    xtype:"pagingtoolbar",
                                    store:"CooperationMemberStore",
                                    displayInfo:true
                            }],
                            selType:"rowmodel",
                            plugins:[
                                Ext.create("ES.view.RowEditingEx",{
                                    pluginId:"RowEditingEx",
                                    clicksToEdit:1
                                })
                            ],
                            columns:[{
                                    header:"成员代码",
                                    width:90,
                                    align:"center",
                                    menuDisabled:true,
                                    sortable:false,
                                    dataIndex:"memberCode",
                                    editor:{
                                        xtype:"textfield",
                                        allowBlank:false
                                    }
                            },{
                                    header:"成员名称",
                                    width:100,
                                    align:"center",
                                    menuDisabled:true,
                                    sortable:false,
                                    dataIndex:"memberName",
                                    editor:{
                                        xtype:"textfield",
                                        allowBlank:false
                                    }
                            },{
                                    header:"联系电话",
                                    width:110,
                                    align:"center",
                                    menuDisabled:true,
                                    sortable:false,
                                    dataIndex:"telPhone",
                                     editor:{
                                        xtype:"textfield",
                                        allowBlank:true
                                    }
                            },{
                                    header:"QQ号码",
                                    width:90,
                                    align:"center",
                                    menuDisabled:true,
                                    sortable:false,
                                    dataIndex:"QQ",
                                    editor:{
                                        xtype:"textfield",
                                        allowBlank:true
                                    }
                            },{
                                    header:"MSN帐号",
                                    width:110,
                                    align:"center",
                                    menuDisabled:true,
                                    sortable:false,
                                    dataIndex:"MSN",
                                    editor:{
                                        xtype:"textfield",
                                        allowBlank:true
                                    }
                            },{
                                    header:"电子邮件地址",
                                    width:128,
                                    flex:1,
                                    align:"center",
                                    menuDisabled:true,
                                    sortable:false,
                                    dataIndex:"emailAddress",
                                    editor:{
                                        xtype:"textfield",
                                        allowBlank:true
                                    }
                            }]
                    }
            }],
            buttons:[{
                        text:"保存",
                        action:"btnSave",
                        formBind:true,
                        disabled:true,
                        tooltip:"保存数据"
                    },{
                        text:"取消",
                        action:"btnCancel",
                        tooltip:"关闭窗口"
                    }]
    },
    initComponent:function(){
        this.callParent(arguments);
    }
})